<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Client Management</title>
<?php $this->view('regions/head'); ?>
</head>
<body>
<div id="wrapper" class="block">
	<?php $this->view('regions/header'); ?>
	<div id="content" class="block">
		<?php if ($this->st_registry->registry('admin/adv/client/message')) :?>
		<div class="stdWidth autoCenter message">
			<?php echo $this->st_registry->getFlashMessage('admin/adv/client/message'); ?>
		</div>
		<?php endif; ?>
		<?php echo form_open_multipart('admin/adv/client/index', array('id' => 'frmClientGridView')); ?>
        <?php echo fx_control::newInstance('formKey')->createType('hidden')->setData('value', random_string('unique', 16))->render(); ?>
        <?php echo fx_control::newInstance('client_ids')->createType('hidden')->setData('value', $client_ids)->render(); ?>
		<div class="gridContainer stdWidth autoCenter">
			<!-- GRID HEADER -->
			<div class="gridHeader block">
				<table class="fullWidth">
					<tr>
						<td class="column50">
							<h3 class="moduleHeader">
								Client Management
							</h3>
						</td>
						<td class="column50 rightAlign">
							<button type="button" onclick="window.location='<?php echo site_url("admin/adv/client/edit", true)?>'">
								<span>Add New Client</span>
							</button>
						</td>
					</tr>
				</table>
			</div>
			<!--TOOL-->
			<div class="gridTools block">
				<table class="fullWidth">
				<tr>
					<td>
						Page
						<?php if ($paginator->getCurrentPageNumber() <= 1) :?>
							<img src="<?php echo base_url() . 'skins/default/images/admin/gridview/pager_arrow_left_off.gif' ?>" align="bottom" border="0"/>
						<?php else: ?>
							<a href="#">
								<img src="<?php echo base_url() . 'skins/default/images/admin/gridview/pager_arrow_left.gif' ?>" align="bottom" border="0" onclick="prevPage('clientPageIndex', 'frmClientGridView')"/>
							</a>
						<?php endif; ?>
							<input type="text" class="inputText pageIndex" id="clientPageIndex" value="<?php echo $paginator->getCurrentPageNumber() ?>" name="page" style="width:20px"/>
						<?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) :?>
							<img src="<?php echo base_url() . 'skins/default/images/admin/gridview/pager_arrow_right_off.gif' ?>" align="bottom" border="0"/>
						<?php else: ?>
							<a href="#">
								<img src="<?php echo base_url() . 'skins/default/images/admin/gridview/pager_arrow_right.gif' ?>" align="bottom" border="0" onclick="nextPage('clientPageIndex', 'frmClientGridView', <?php echo $paginator->count() ?>)"/>
							</a>
						<?php endif; ?>
						of <?php echo $paginator->count() ?> pages
						<span class="separator">|</span>
						View
						<?php echo fx_control::newInstance('recordPerPage')
									 ->createType('option')
									 ->addOption('20', 20)
									 ->addOption('30', 30)
									 ->addOption('50', 50)
									 ->addOption('100', 100)
									 ->addOption('200', 200)
									 ->addClass('selectRecordPerPage')
									 ->bindingOption($paginator, 'getItemCountPerPage')
									 ->render(); 
						?>
						on page
						<span class="separator">|</span>
						Total <?php echo $model->countAll(); ?> clients, found
						<span class="no-display" id="total-count"><?php echo $found; ?></span> clients
					</td>
					<td align="right">
						&nbsp;
					</td>
					<td align="right">
						<div align="right" class="buttonSet">
							<button type="submit">
								<span>Search</span>
							</button>
							<button type="reset" id="btnResetGridForm" onclick="window.location='<?php echo site_url('admin/adv/client/index', true); ?>'">
								<span>Reset Filter</span>
							</button>
						</div>
					</td>
				</tr>
				</table>
			</div>
			<!--MASSAGE ACTION-->
			<table class="massTool fullWidth" id="massTool">
				<tr>
					<td>
						<a href="#" onclick="return selectAll('chkClient', 'client_ids', '<?php echo site_url('admin/grid/select/adv_client_model',true)?>', 'clientItemSelected', 'clientSelectedValueHidden')"><span>Select All</span></a>
						<span>|</span>
						<a href="#" onclick="return unSelectAll('chkClient', 'client_ids', 'clientItemSelected', 'clientSelectedValueHidden')"><span>Unselect All</span></a>
						<span>|</span>
						<a href="#" onclick="return selectVisible('chkClient', 'client_ids', 'clientItemSelected', 'clientSelectedValueHidden')"><span>Select Visible</span></a>
						<span>|</span>
						<a href="#" onclick="return unSelectVisible('chkClient', 'client_ids', 'clientItemSelected', 'clientSelectedValueHidden')"><span>Unselect Visible</span></a>
						&nbsp;
						<strong id="clientItemSelected" name="client_selected"><?php echo $client_selected ?></strong>
						item selected
						<input type="hidden" name="client_selected" value="<?php echo $client_selected ?>" id="clientSelectedValueHidden" />
					</td>
					<td class="rightAlign">
						Select action
						<?php echo fx_control::newInstance('selectMassAction')
									 ->createType('option')
									 ->addOption('', '')
									 ->addOption('Delete', site_url("admin/adv/client/massDelete", true))
									 ->addClass('massSelectAction')
									 ->addClass('stdSelect')
									 ->render(); 
						?>
						<input type="text" id="categorySetterId" name="categorySetterId" value="input category id ..." class="hide" />
						<input type="text" id="publishDay" name="publishDay" value="2011-12-23" class="hide" />
						<input type="button" id="btnActiveAction" value="Action" onclick="activeMassAction('frmClientGridView', 'selectMassAction')" />
					</td>
				</tr>
			</table>			
	        <!--PRODUCT COLLECTION-->
			<table class="gridview" id="gridview">
				<thead>
				<!--COLUMN HEADER-->
				<tr class="columns">
					<input type="hidden" name="clientOrder[name]" value="<?php echo $sorter->getName() ?>" id="clientOrder"/>
					<input type="hidden" name="clientOrder[direction]" value="<?php echo $sorter->getDirection() ?>" id="clientOrderDirection"/>
					<th><span></span></th>
					<th id="client_id" class="columnFilter"><span>ID</span></th>
					<th id="client_first_name" class="columnFilter"><span>First Name</span></th>
					<th id="client_last_name" class="columnFilter"><span>Last Name</span></th>
					<th id="client_email" class="columnFilter"><span>Email</span></th>
					<th id="client_company" class="columnFilter"><span>Company</span></th>
					<th><span>Action</span></th>
				</tr>
				<!--COLUMN FILTER-->
				<tr class="filters">
					<th style="width: 30px"></th>
					<th style="width: 120px">
						<div class="clear">
							<span class="filterLabel left">From</span>
							<input class="filterField left" type="text" name="clientFilter[id][value][from]" value="<?php echo $filters->getValueFrom('id'); ?>"/>
							<input type="hidden" name="clientFilter[id][type]" value="range"/>
						</div>
						<div class="clear">
							<span class="filterLabel left">To</span>
							<input class="filterField left" type="text" name="clientFilter[id][value][to]" value="<?php echo $filters->getValueTo('id'); ?>"/>
						</div>
					</th>
					<th>
						<div class="clear">
							<input type="text" name="clientFilter[first_name][value]" value="<?php echo $filters->getValue('first_name'); ?>" style="width: 89%"/>
							<input type="hidden" name="clientFilter[first_name][type]" value="string"/>
						</div>						
					</th>
					<th>
						<div class="clear">
							<input type="text" name="clientFilter[last_name][value]" value="<?php echo $filters->getValue('last_name'); ?>" style="width: 89%"/>
							<input type="hidden" name="clientFilter[last_name][type]" value="string"/>
						</div>						
					</th>
					<th>
						<div class="clear">
							<input type="text" name="clientFilter[email][value]" value="<?php echo $filters->getValue('email'); ?>" style="width: 89%"/>
							<input type="hidden" name="clientFilter[email][type]" value="string"/>
						</div>						
					</th>
					<th>
						<div class="clear">
							<input type="text" name="clientFilter[company][value]" value="<?php echo $filters->getValue('company'); ?>" style="width: 89%"/>
							<input type="hidden" name="clientFilter[company][type]" value="string"/>
						</div>						
					</th>
					<th></th>
				</tr>
				</thead>
				<tbody>
					<?php foreach ($collection as $client) :?>
					<tr id="row_<?php echo $client->getId()?>" class="activeRow">
						<input class="editUrl" type="hidden" value="<?php echo $client->getClientUrl(); ?>" />
						<td class="noActiveRow">
							<?php echo fx_control::newInstance('client_checkbox[]')
												 ->createType('checkbox')
												 ->value($client->getId())
												 ->addClass('chkClient')
												 ->removeClass('inputText')
												 ->bindingCheckbox($client_ids_array)
												 ->render();
							?>
						</td>
						<td><?php echo $client->getId() ?></td>
						<td><?php echo $client->getFirstName() ?></td>
						<td><?php echo $client->getLastName() ?></td>
						<td><?php echo $client->getEmail() ?></td>
						<td><?php echo $client->getCompany() ?></td>
						<td>
							<a href="<?php echo $client->getClientUrl() ?>">Edit</a>
							&nbsp;
							<a href="<?php echo site_url('admin/adv/client/delete/id/'.$client->getId(), true) ?>">Delete</a>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
		</div>
		<?php echo form_close(); ?>
	</div>
	<?php $this->view('regions/footer'); ?>
	<script language="javascript" type="text/javascript">
		jQuery("#gridview")
		.decorateTable()
		.lightHoverRow()
		.activeSortableAbility("frmClientGridView", "columnFilter", "client_", "clientOrder", "clientOrderDirection")
		.checkboxCallbackHandler('chkClient', 'client_ids', 'clientItemSelected', 'clientSelectedValueHidden')
		.activeEditRow();
	</script>
</div>
</body>
</html>
